<?phpclass Slide_model extends CI_Model {    public function __construct() {        parent::__construct();        $this->load->database();        $this->load->model('post_photo_model');        $this->load->model('photo_model');    }        public function get() {        return $this->db->get('slide')->result_array();    }        public function update($slides) {        $this->db->update_batch('slide', $slides, 'slide_id');        return $this->db->affected_rows();    }        public function get_mainpage() {        $slides = $this->get();        for($i = 0; $i < count($slides); $i++) {            $slide_cover_id = $slides[$i]['slide_cover_id'];            if ($slide_cover_id != 0) {                $slides[$i]['photo'] = $this->photo_model->get($slide_cover_id);            } else {                $slides[$i]['photo'] = $this->post_photo_model->get_one($slides[$i]['post_id']);            }        }        return $slides;    }}?>